package com.leyou.search.web;


import com.leyou.search.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("goods")
public class IndexController {


    @Autowired
    private IndexService indexService;


    /**
     * 风险:现在 loadData方法中是先删除索引库再 增加索引库  这样就一直存不了老数据
     * 建库 最好要跟删库 业务分开
     *
     *
     * @return
     */
    @GetMapping("/init")
    public ResponseEntity<String> initIndexes(){
        this.indexService.loadData();//创建索引库,并且 存数据
        return ResponseEntity.ok("索引库初始化完成");

    }



}
